/*
//              INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license  agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in  accordance  with the terms of that agreement.
//    Copyright (c) 2007 Intel Corporation. All Rights Reserved.
//
*/
#include "umc_defs.h"
#if defined (UMC_ENABLE_DVHD_VIDEO_ENCODER)

#ifndef __DV100_SEGMENT_COMPRESSOR_H
#define __DV100_SEGMENT_COMPRESSOR_H

#include "umc_dv_enc_segment_compressor.h"
#include "umc_dv_enc_compressor_def.h"
#include "umc_structures.h"

namespace UMC
{

enum DV100VideoFormat
{
    mSystem1080_60i, //1920 x 1080 image, 59.94 Hz field rate, interlace format
    mSystem1080_50i, //1920 x 1080 image, 50 Hz field rate, interlace format
    mSystem720_60p,   //1280 x 720 image, 59.94 Hz field rate, progressive format
    mSystem720_50p   //1280 x 720 image,  50 Hz field rate, progressive format
};


struct SQuantTableElem
{
    Ipp32s QuantStep;
    Ipp32s QNO;
    Ipp32s ClassNum;
};

class DV100SegmentCompressor : public SegmentCompressor
{
public:
    DV100SegmentCompressor(void);
    ~DV100SegmentCompressor(void);

    // compress DV segment
    virtual void CompressSegment(struct DV_SEGMENT *lpDVSegment);

    DV100VideoFormat m_VideoFormat;

protected:
    void DoDCT();
    void ZigZagDCTBlocks();
    void DoQuantizationAndWeighting(struct DV_SEGMENT *lpDVSegment);

    Ipp32s ComputeSegmentSize(Ipp32s ClassNum, Ipp32s QNO);
    Ipp32s GetEncodedQuantizedDCTBlockBitLength(BLOCK *pDCTBlock, Ipp32s ClassNum, Ipp32s QNO, const Ipp32u *QuantizeMatrix);
    void QuantizeDCTBlock(BLOCK *pDCTBlock, Ipp32s ClassNum, Ipp32s QNO, const Ipp32u *QuantizeMatrix);

    static const Ipp32u QuantizationSteps[];
    static const Ipp32u LumaQuantizeMatrix_1080System[64];
    static const Ipp32u ChromaQuantizeMatrix_1080System[64];
    static const Ipp32u LumaQuantizeMatrix_720System[64];
    static const Ipp32u ChromaQuantizeMatrix_720System[64];
    static const SQuantTableElem QuantizeTable[];

    Ipp32s m_iQuantPredictor;
};

}

#endif //__DV100_SEGMENT_COMPRESSOR_H

#endif // (UMC_ENABLE_DVHD_VIDEO_ENCODER)
